package com.xin.motion
{
/**
 * 平行执行动画播放
 * @author daichangxin
 */
public class ParallelAnimation extends AnimationBase
{
	private var _animationList:Vector.<AnimationBase>;
	public function ParallelAnimation()
	{
		super(0);
		init();
	}
	
	private function init():void
	{
		_animationList = new Vector.<AnimationBase>();
	}
	
	/**
	 * 添加动画到平行播放数组
	 */
	public function push(animation:AnimationBase):void
	{
		_duration = Math.max(_duration, animation.duration);
		_animationList.push(animation);
	}

	override public function set elapsed(value : uint) : void
	{
		super.elapsed = value;
		
		for (var i : int = 0; i < _animationList.length; i++) 
		{
			var itemAnimation:AnimationBase = _animationList[i];
			if (itemAnimation.duration >= value)
			{
				itemAnimation.elapsed = value;
			}
			else
			{
				_animationList.splice(i, 1);
			}
		}
	}

}
}
